﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
/// Summary description for tabsclass
/// </summary>
public class BLL
{
    DataTable td, tdpd;
    GetDishFromDataBaseDataSetTableAdapters.DishTableAdapter obj = new GetDishFromDataBaseDataSetTableAdapters.DishTableAdapter();
    getCmterordersDataSetTableAdapters.FinalOrderTableAdapter obj1 = new getCmterordersDataSetTableAdapters.FinalOrderTableAdapter();
    GetSetRegesterTableAdapters.RegesterTableAdapter objreg = new GetSetRegesterTableAdapters.RegesterTableAdapter();
    CustomerTblDataSetTableAdapters.CustomerTblTableAdapter objcus = new CustomerTblDataSetTableAdapters.CustomerTblTableAdapter();
    CompanyTableAdapters.CompanyNameTableAdapter objcom = new CompanyTableAdapters.CompanyNameTableAdapter();
    CatgDataSetTableAdapters.CategoriesTableAdapter objcat = new CatgDataSetTableAdapters.CategoriesTableAdapter();
    DefualtSettingDataSetTableAdapters.DefaultSettingTableAdapter objDS = new DefualtSettingDataSetTableAdapters.DefaultSettingTableAdapter();
    AddSettingDataSetTableAdapters.AddsSettingTableAdapter objAddSt = new AddSettingDataSetTableAdapters.AddsSettingTableAdapter();
    NotificationSettingDataSetTableAdapters.NotificationSettingTableAdapter objnotif = new NotificationSettingDataSetTableAdapters.NotificationSettingTableAdapter();

    public GetDishFromDataBaseDataSet.DishDataTable Dlfill1()
    {
        return obj.GetDataone();
    }

    public GetDishFromDataBaseDataSet.DishDataTable Dlfill2(int Ct)
    {
        return obj.GetDatatwo(Ct);
    }

    public int dv(string s)
    {
        return Convert.ToInt32(obj.GetDataDishStock(s));
    }

    public DataTable cretetable()
    {
        td = new DataTable();
        td.Columns.Add("DishName", typeof(string));
        td.Columns.Add("DishQty", typeof(int));
        td.Columns.Add("DishIndvPrice", typeof(int));
        td.Columns.Add("DishPrice", typeof(float));
        return td;
    }

    public void InsertOrder(string s1, string s2, string s3, double s4, int s5, DateTime s6, int CTID)
    {
        obj1.InsertOrder(s1, s2, s3, s4, s5, s6, CTID);
    }

    public void updatestock(int i,string s)
    {
        obj.UpdateQuery(i, s);
    }

    public int wbal(string ID)
    {
        //int r;
        //try
        //{
        //    r = Convert.ToInt32(objreg.GetWALbaL(ID));
        //}
        //catch
        //{
        //    r = 0;
        //}
        //return r;

        //return Convert.ToInt32(objreg.GetWALbaL(ID));

        return Convert.ToInt32(objreg.ScalarQueryGetWalBal2(ID));
    }   

    public int getduplicredester(string s)
    {
        return Convert.ToInt32(objreg.ScalarQuery(s));
    }

    public int RegesterInsert(string s1,string s2,string s3,string s4,string s5)
    {
        int r;
        try 
        {
            objreg.InsertQuery(s1, s2, s3, s4, s5);
            r = 1;
        }
        catch 
        {
            r = 2;
        }
        finally 
        { 
        }
        return r;
    }

    public int loginavl(string s1, string s2)
    {
        return Convert.ToInt32(objreg.ScalarLogin(s1, s2));
    }

    public string getCusName(string s1)
    {
        return (string)objreg.GetCName(s1);
    }

    //not in use
    public getCmterordersDataSet.FinalOrderDataTable getDetailsWithWalBalance(string ID)
    {
        return obj1.GetWalBalandCDetails(ID); 
        //not in use
    }

    public getCmterordersDataSet.FinalOrderDataTable getCushistory(string ID)
    {
        return obj1.GetCustomer(ID);
    }

    public int ChangePersonalDetails(string ID, string OPSW)
    {
        return Convert.ToInt32(objreg.ScalarQChangeDetails(ID, OPSW));
    }

    public int ChangePassword(string NPSW,string ID)
    {
        int r;
        try
        {
            objreg.UpdateQueryNewPassword(NPSW, ID);
            r = 1;
        }
        catch
        {
            r = 2;
        }
        finally
        {
        }
        return r; 
    }

    public int SetPrsonalDetails(string NM,string Em,string ADD, string ID)
    {
        return objreg.SetProsonalData(NM, Em, ADD, ID);
    }

    public DataSet GETPD(string ID)
    {
        DAL DALObj = new DAL();
        return DALObj.PD(ID);
    }

    public void InsertOrderWithWALBalan(string CN, string CI, string DN, double DP, int DQ, DateTime DT, int WB,int CTID)
    {
        obj1.InsertQueryWithWalBAlDeduct(CN, CI, DN, DP, DQ, DT, WB, CTID);
    }

    public int  GetWBalfrmOrderTab(string ID)
    {
        return Convert.ToInt32(obj1.SumQueryAddWalBal(ID));
    }

    public int GetDebitWalfrmOrdelTable(string ID)
    {
        return Convert.ToInt32(obj1.ScalarBalDeduct(ID));
    }

    public void UpdateWB(int wb, string ID)
    {
        objreg.UpdateQueryWallwtBal(wb, ID);
    }

    public void SetOrderSummery(int price, DateTime DT, int BlD, string ID)
    {
        objcus.InsertQuerySetOrederSummery(price, DT, BlD, ID);
    }

    public CustomerTblDataSet.CustomerTblDataTable FillORHistory(string ID)
    {
        return objcus.GetDataByCID(ID);
    }

    public getCmterordersDataSet.FinalOrderDataTable GetPopUp(string ID,int CTID)
    {
        return obj1.GetDataForPopUp(ID, CTID);
    }

    public int GetOrederlID(string ID, DateTime DT)
    {
        return Convert.ToInt32(objcus.FillByID(ID, DT));
    }

    public Company.CompanyNameDataTable getCompanyName()
    {
         return objcom.GetDataBy();
    }

    public string GetPassword(string EmID, string ID)
    {
        return (string)objreg.FillGetPassword(EmID, ID);
    }
    public CatgDataSet.CategoriesDataTable useforlabelbutton()
    {
        return objcat.GetData();
    }
    public DefualtSettingDataSet.DefaultSettingDataTable defaultSetings()
    {
        return objDS.GetData();
    }
    public CustomerTblDataSet.CustomerTblDataTable GetOrderSummeryForSMS(DateTime DT,String ID)
    {
        return objcus.GetDataForSMS(ID, DT);
    }
    public AddSettingDataSet.AddsSettingDataTable AddSetting()
    {
        return objAddSt.GetData();
    }
    public NotificationSettingDataSet.NotificationSettingDataTable NotificationForDisplay()
    {
        return objnotif.GetDataForNotiDisplay();
    }
}